package org.phalanx.server.user;

import org.phalanx.server.PhalanxServer;
import org.phalanx.server.ServerCache.Cache;
import org.phalanx.server.ServerCache.CacheManager;

public class SimpleUserCache {
	public static SimpleUserCache simpleCache;
	private Cache userCache;
	private Cache sessionCache;
	private Cache loginCache;
	
	synchronized public static SimpleUserCache getInstance(){
		if (simpleCache == null){
			simpleCache = new SimpleUserCache();
		}
		return simpleCache;
	}
	
	synchronized public static void  removeInstance(){
		if (simpleCache != null){
			simpleCache = null;
		}
	}
	
	public SimpleUserCache(){
		CacheManager cm = PhalanxServer.getServerInstance().getCacheManager();
		
		userCache = cm.getCache("UserCache");
		sessionCache = cm.getCache("ChatSessionManagerCache");
		loginCache = cm.getCache("UserLoginCache");
	}
	
	public Object getFromUserCache(String key){
		Object userObject = null;
		
		userObject = userCache.get(key);
		
		return userObject;
	}
}
